package top.jlzhou.jobs.controller;


import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import top.jlzhou.R;
import top.jlzhou.jobs.entity.JobInfo;
import top.jlzhou.jobs.service.JobInfoService;
import top.jlzhou.jobs.vo.Param1;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author J.L.Zhou
 * @since 2018-10-22
 */
@Controller
@RequestMapping("/job")
public class JobInfoController {

	@Autowired
	private JobInfoService service;
	
	@RequestMapping("get")
	@ResponseBody
	public R doGet(Long token) {
		try {
			return R.ok().put("job", service.getNewJob(token));
		}catch (Exception e) {
			return R.error(e.getMessage());
		}
	}
	
	@RequestMapping("save")
	@ResponseBody
	public R doSave(@RequestParam(name="token",required=true,defaultValue="123456") Long token,JobInfo job) {
		try {
			service.saveJob(token,job);
			return R.ok();
		}catch (Exception e) {
			return R.error(e.getMessage());
		}
	}
	
	@RequestMapping("p")
	@ResponseBody
	public Object doParam1(@RequestBody Param1 p){
		
		return p;
	}
	
}

